%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/posts"
    Bucket0("Bucket 0 (root)<br /><br />1: 86, 94, 98<br />ᐳ: 6, 9, 10, 43, 49, 11, 25, 62<br />2: PgSelectInlineApply[90]<br />3: PgSelectInlineApply[102]<br />4: PgSelect[8]<br />ᐳ: Access[19], Access[103]<br />5: Connection[12]<br />6: ConnectionItems[14]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 19, 14, 103<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 19, 103<br /><br />ROOT __Item{3}ᐸ14ᐳ[17]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 17, 18, 103, 20<br /><br />ROOT Edge{3}[18]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 21, 103<br /><br />ROOT PgSelectSingle{4}ᐸpostᐳ[21]<br />1: <br />ᐳ: 22, 23, 26, 104, 105<br />2: PgSelectRows[33]<br />ᐳ: First[32], PgSelectSingle[34]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 34, 105, 32<br /><br />ROOT PgSelectSingle{5}ᐸpersonᐳ[34]<br />1: <br />ᐳ: 35, 36, 38, 91, 95, 99, 92, 93, 96, 97, 100, 101, 76<br />2: 45, 50, 58<br />ᐳ: 44, 46, 57, 59, 60, 64<br />3: ConnectionItems[52]<br />ᐳ: First[75], PgCursor[77]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 46, 93<br /><br />ROOT PgSelectSingle{6}ᐸperson_first_postᐳ[46]<br />1: <br />ᐳ: 51, 55, 63, 87, 88, 89<br />2: PgSelectRows[71]<br />ᐳ: First[70], PgSelectSingle[72]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 72<br /><br />ROOT PgSelectSingle{7}ᐸpersonᐳ[72]"):::bucket
    Bucket10("Bucket 10 (listItem)<br /><br />ROOT __Item{10}ᐸ52ᐳ[73]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 74<br /><br />ROOT PgSelectSingle{10}ᐸperson_friendsᐳ[74]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6
    Bucket6 --> Bucket7 & Bucket10
    Bucket7 --> Bucket9
    Bucket10 --> Bucket11

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸpostᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgFromExpression25{{"PgFromExpression[25∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]"}}:::plan
    PgFromExpression43{{"PgFromExpression[43∈0] ➊"}}:::plan
    PgFromExpression62{{"PgFromExpression[62∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]"}}:::plan
    PgFromExpression49{{"PgFromExpression[49∈0] ➊"}}:::plan
    PgSelectInlineApply102["PgSelectInlineApply[102∈0] ➊"]:::plan
    Object11 & PgFromExpression25 & PgFromExpression43 & PgFromExpression62 & PgFromExpression49 & PgSelectInlineApply102 --> PgSelect8
    PgSelectInlineApply90["PgSelectInlineApply[90∈0] ➊"]:::plan
    PgSelectInlineApply94["PgSelectInlineApply[94∈0] ➊"]:::plan
    PgSelectInlineApply98["PgSelectInlineApply[98∈0] ➊"]:::plan
    PgSelectInlineApply90 & PgSelectInlineApply94 & PgSelectInlineApply98 --> PgSelectInlineApply102
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    ConnectionItems14[["ConnectionItems[14∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems14
    Access19{{"Access[19∈0] ➊<br />ᐸ8.cursorDetailsᐳ"}}:::plan
    PgSelect8 --> Access19
    PgSelectInlineApply86["PgSelectInlineApply[86∈0] ➊"]:::plan
    PgSelectInlineApply86 --> PgSelectInlineApply90
    Access103{{"Access[103∈0] ➊<br />ᐸ8.m.joinDetailsFor28ᐳ"}}:::plan
    PgSelect8 --> Access103
    Edge18{{"Edge[18∈3]"}}:::plan
    __Item17[/"__Item[17∈3]<br />ᐸ14ᐳ"\]:::itemplan
    PgCursor20{{"PgCursor[20∈3]"}}:::plan
    __Item17 & PgCursor20 --> Edge18
    __Item17 & Access19 --> PgCursor20
    ConnectionItems14 ==> __Item17
    PgSelectSingle21{{"PgSelectSingle[21∈4]<br />ᐸpostᐳ"}}:::plan
    __Item17 --> PgSelectSingle21
    List104{{"List[104∈5]<br />ᐸ103,21ᐳ"}}:::plan
    Access103 & PgSelectSingle21 --> List104
    PgClassExpression22{{"PgClassExpression[22∈5]<br />ᐸ__post__.”id”ᐳ"}}:::plan
    PgSelectSingle21 --> PgClassExpression22
    PgClassExpression23{{"PgClassExpression[23∈5]<br />ᐸ__post__.”headline”ᐳ"}}:::plan
    PgClassExpression22 o--o PgClassExpression23
    PgClassExpression26{{"PgClassExpression[26∈5]<br />ᐸ(1/0) /* E...ferred! */ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression26
    First32{{"First[32∈5]"}}:::plan
    PgSelectRows33[["PgSelectRows[33∈5]"]]:::plan
    PgSelectRows33 --> First32
    Lambda105{{"Lambda[105∈5]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda105 --> PgSelectRows33
    PgSelectSingle34{{"PgSelectSingle[34∈5]<br />ᐸpersonᐳ"}}:::plan
    First32 --> PgSelectSingle34
    List104 --> Lambda105
    PgCursor77{{"PgCursor[77∈6]"}}:::plan
    First75{{"First[75∈6]"}}:::plan
    Access76{{"Access[76∈6]<br />ᐸ97.cursorDetailsᐳ"}}:::plan
    First75 & Access76 --> PgCursor77
    List92{{"List[92∈6]<br />ᐸ91,34ᐳ"}}:::plan
    Access91{{"Access[91∈6]<br />ᐸ105.m.joinDetailsFor39ᐳ"}}:::plan
    Access91 & PgSelectSingle34 --> List92
    List96{{"List[96∈6]<br />ᐸ95,32ᐳ"}}:::plan
    Access95{{"Access[95∈6]<br />ᐸ105.m.subqueryDetailsFor47ᐳ"}}:::plan
    Access95 & First32 --> List96
    List100{{"List[100∈6]<br />ᐸ99,32ᐳ"}}:::plan
    Access99{{"Access[99∈6]<br />ᐸ105.m.subqueryDetailsFor56ᐳ"}}:::plan
    Access99 & First32 --> List100
    PgClassExpression35{{"PgClassExpression[35∈6]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle34 --> PgClassExpression35
    PgClassExpression36{{"PgClassExpression[36∈6]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression35 o--o PgClassExpression36
    PgClassExpression38{{"PgClassExpression[38∈6]<br />ᐸ”c”.”perso..._person__)ᐳ"}}:::plan
    PgClassExpression36 o--o PgClassExpression38
    First44{{"First[44∈6]"}}:::plan
    PgSelectRows45[["PgSelectRows[45∈6]"]]:::plan
    PgSelectRows45 --> First44
    Lambda93{{"Lambda[93∈6]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda93 --> PgSelectRows45
    PgSelectSingle46{{"PgSelectSingle[46∈6]<br />ᐸperson_first_postᐳ"}}:::plan
    First44 --> PgSelectSingle46
    Connection50[["Connection[50∈6]<br />ᐸ97ᐳ"]]:::plan
    Lambda97{{"Lambda[97∈6]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda97 --> Connection50
    ConnectionItems52[["ConnectionItems[52∈6]"]]:::plan
    Connection50 --> ConnectionItems52
    First57{{"First[57∈6]"}}:::plan
    PgSelectRows58[["PgSelectRows[58∈6]"]]:::plan
    PgSelectRows58 --> First57
    Lambda101{{"Lambda[101∈6]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda101 --> PgSelectRows58
    PgSelectSingle59{{"PgSelectSingle[59∈6]<br />ᐸperson_friendsᐳ"}}:::plan
    First57 --> PgSelectSingle59
    PgClassExpression60{{"PgClassExpression[60∈6]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle59 --> PgClassExpression60
    PageInfo64{{"PageInfo[64∈6]"}}:::plan
    Connection50 --> PageInfo64
    ConnectionItems52 --> First75
    Lambda97 --> Access76
    Lambda105 --> Access91
    List92 --> Lambda93
    Lambda105 --> Access95
    List96 --> Lambda97
    Lambda105 --> Access99
    List100 --> Lambda101
    List88{{"List[88∈7]<br />ᐸ87,46ᐳ"}}:::plan
    Access87{{"Access[87∈7]<br />ᐸ93.m.joinDetailsFor66ᐳ"}}:::plan
    Access87 & PgSelectSingle46 --> List88
    PgClassExpression51{{"PgClassExpression[51∈7]<br />ᐸ__person_f...ost__.”id”ᐳ"}}:::plan
    PgSelectSingle46 --> PgClassExpression51
    PgClassExpression55{{"PgClassExpression[55∈7]<br />ᐸ__person_f...”headline”ᐳ"}}:::plan
    PgClassExpression51 o--o PgClassExpression55
    PgClassExpression63{{"PgClassExpression[63∈7]<br />ᐸ(1/0) /* E...ferred! */ᐳ"}}:::plan
    PgClassExpression55 o--o PgClassExpression63
    First70{{"First[70∈7]"}}:::plan
    PgSelectRows71[["PgSelectRows[71∈7]"]]:::plan
    PgSelectRows71 --> First70
    Lambda89{{"Lambda[89∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda89 --> PgSelectRows71
    PgSelectSingle72{{"PgSelectSingle[72∈7]<br />ᐸpersonᐳ"}}:::plan
    First70 --> PgSelectSingle72
    Lambda93 --> Access87
    List88 --> Lambda89
    PgClassExpression78{{"PgClassExpression[78∈9]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle72 --> PgClassExpression78
    PgClassExpression79{{"PgClassExpression[79∈9]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression78 o--o PgClassExpression79
    PgClassExpression81{{"PgClassExpression[81∈9]<br />ᐸ”c”.”perso..._person__)ᐳ"}}:::plan
    PgClassExpression79 o--o PgClassExpression81
    __Item73[/"__Item[73∈10]<br />ᐸ52ᐳ"\]:::itemplan
    ConnectionItems52 ==> __Item73
    PgSelectSingle74{{"PgSelectSingle[74∈10]<br />ᐸperson_friendsᐳ"}}:::plan
    __Item73 --> PgSelectSingle74
    PgClassExpression82{{"PgClassExpression[82∈11]<br />ᐸ__person_friends__.”id”ᐳ"}}:::plan
    PgSelectSingle74 --> PgClassExpression82
    PgClassExpression83{{"PgClassExpression[83∈11]<br />ᐸ__person_f...full_name”ᐳ"}}:::plan
    PgClassExpression82 o--o PgClassExpression83
    PgClassExpression85{{"PgClassExpression[85∈11]<br />ᐸ”c”.”perso...friends__)ᐳ"}}:::plan
    PgClassExpression83 o--o PgClassExpression85

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,ConnectionItems14,Access19,PgFromExpression25,PgFromExpression43,PgFromExpression49,PgFromExpression62,PgSelectInlineApply86,PgSelectInlineApply90,PgSelectInlineApply94,PgSelectInlineApply98,PgSelectInlineApply102,Access103 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item17,Edge18,PgCursor20 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle21 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression22,PgClassExpression23,PgClassExpression26,First32,PgSelectRows33,PgSelectSingle34,List104,Lambda105 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression35,PgClassExpression36,PgClassExpression38,First44,PgSelectRows45,PgSelectSingle46,Connection50,ConnectionItems52,First57,PgSelectRows58,PgSelectSingle59,PgClassExpression60,PageInfo64,First75,Access76,PgCursor77,Access91,List92,Lambda93,Access95,List96,Lambda97,Access99,List100,Lambda101 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression51,PgClassExpression55,PgClassExpression63,First70,PgSelectRows71,PgSelectSingle72,Access87,List88,Lambda89 bucket7
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression78,PgClassExpression79,PgClassExpression81 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,__Item73,PgSelectSingle74 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression82,PgClassExpression83,PgClassExpression85 bucket11

